package com.example.presentshopping.ui.custom;

import android.os.SystemClock;
import android.view.View;

public abstract class NoDoubleClickListener implements View.OnClickListener{
    public static final int MIN_CLICK_DELAY_TIME = 1000;//这里设置不能超过多长时间
    private long lastClickTime ;

    protected abstract void onNoDoubleClick(View v) throws Exception;
    @Override
    public void onClick(View v) {
        long currentTime= SystemClock.uptimeMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            try {
                onNoDoubleClick(v);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        lastClickTime= currentTime;
    }



}
